package resp

import (
	"github.com/labstack/echo"
	"net/http"
)

func Success(c echo.Context, msg ...string) error {
	res := MakeSuccessResponse(msg...)
	return c.JSON(http.StatusOK, res)
}

func Data(c echo.Context, data interface{}) error {
	res := MakeSuccessDataResponse(data)
	return c.JSON(http.StatusOK, res)
}

func List(c echo.Context, data interface{}) error {
	if data == nil {
		data = make([]interface{}, 0)
	}
	res := MakeSuccessDataResponse(data)
	return c.JSON(http.StatusOK, res)
}

func Page(c echo.Context, data interface{}, page PageFields) error {
	if data == nil {
		data = make([]interface{}, 0)
	}
	res := MakeSuccessDataPageResponse(data, page)
	return c.JSON(http.StatusOK, res)
}

func Query(c echo.Context, data interface{}, page PageFields, params interface{}) error {
	res := MakeSuccessDataPageResponse(data, page)
	res.Params = params
	return c.JSON(http.StatusOK, res)
}

func Fail(c echo.Context, msg string) error {
	res := &Response{
		Status:  false,
		Massage: msg,
	}
	return c.JSON(http.StatusOK, res)
}

func Error(c echo.Context, err error) error {
	res := MakeErrorResponse(err)
	return c.JSON(http.StatusOK, res)
}

func Confirm(c echo.Context, msg string) error {
	res := &Response{
		Status:  false,
		Massage: msg,
	}
	return c.JSON(http.StatusOK, res)
}
